package cs.sy.service.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cs.sy.common.util.TimeTools;
import cs.sy.service.business.UserLoginBuss;

public class DelOrderServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		try{
			int id = Integer.parseInt(req.getParameter("id").toString());
			if(new UserLoginBuss().delOrderById(id)){
					req.setAttribute("alldata", new UserLoginBuss().getAllDataByDate());
					req.setAttribute("date", TimeTools.getDate());
					req.getRequestDispatcher("/foodDetail.jsp").forward(req, resp);
			}else{
				req.setAttribute("result", "内部错误,操作失败...");
				req.getRequestDispatcher("/foodDetail.jsp").forward(req, resp);
			}
		}catch (Exception e) {
			req.setAttribute("result", "内部错误,操作失败...");
			req.getRequestDispatcher("/foodDetail.jsp").forward(req, resp);
		}
	}
	
}
